import Vue from 'vue'
import Vuex from 'vuex'
import persistedState from 'vuex-persistedstate'
Vue.use(Vuex)

import cities from './cities'
import loginModule from './login'

const state = {
  isTabBarShow: true
}

const mutations = {
  tabBarShow(state) {
    state.isTabBarShow = true
  },
  tabBarHide(state) {
    state.isTabBarShow = false
  }
}

const getters = {}

const actions = {}

const store = new Vuex.Store({
  plugins: [
    persistedState({
      reducer(val) {
        return {
          // 只储存state中的token
          cities: val.cities
        }
      }
    })
  ],
  state,
  mutations,
  getters,
  actions,
  modules: {
    cities,
    loginModule
  }
})

export default store
